<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<div>
    <table id="wQbdPressureElementInfoTable" lay-filter="wQbdPressureElementInfoTable"></table>
    <form class="reportList-isShow">
        <input type="hidden" id="successDataId" name="successDataId">
    </form>
</div>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdPressureElementInfoRightToolsBar">
    <a class="RightBtn" lay-event="particulars">详情</a>
</script>

<script>
    //一般直接写在一个js文件中
    layui.use(['table',  'common','publicMethods','jquery','layer'], function () {
        var table = layui.table;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;

        var tableH=publicMethods.layerHeight();
        var dataId = "${dataId}";

        //第一个实例
        table.render({
            elem: '#wQbdPressureElementInfoTable'
            ,height:tableH
            ,url:  '${ctx}/qbdms/wQbdPressureElementInfo/reportList?id='+dataId+"&tableName=W_QBD_PRESSURE_ELEMENT_INFO"
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                , {field: 'componentCategory', title: '元件类别',minWidth:110}
                , {field: 'businessCategory', title: '企业类别',minWidth:110}
                , {field: 'batchNumber', title: '批次号',minWidth:100}
                , {
                    field: 'testSumPerformanceTesting',
                    title: '检测总件数-性能检测',minWidth:180
                }
                ,{
                    field: 'testSumSizeDetection',
                    title: '检测总件数-尺寸检测',minWidth:180
                }
                ,{
                    field: 'failedPerformanceTesting',
                    title: '不合格件数-性能检测',minWidth:180
                }
                ,{
                    field: 'failedSizeDetection',
                    title: '不合格件数-尺寸检测',minWidth:180
                }
                ,{
                    fixed: 'right',
                    title: '管理',
                    width:80,
                    align:'center',
                    toolbar: '#wQbdPressureElementInfoRightToolsBar'
                }
            ]],done:function () {
            }
        });

        table.on('tool(wQbdPressureElementInfoTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "particulars":
                    var height=publicMethods.layHeight('body');
                    layer.open({
                        type: 2,
                        area: ['96%', height],
                        title: ['压力元件信息详情'],
                        content:  '${ctx}/qbdms/wQbdPressureElementInfo/view/particulars?id='+data.id + "&isClose=true"
                    });
                    break;
            }
        });

        table.on('checkbox(wQbdPressureElementInfoTable)', function(obj){
            if(obj.type == "all"){
                if(obj.checked){
                    $("input[name='successDataId']").val("");
                    var checkStatus = table.checkStatus('wQbdPressureElementInfoTable');
                    var valArr = checkStatus.data;//选中行数据
                    var ceshiVal = $("input[name='successDataId']").val();
                    for(var i=0;i<valArr.length;i++){
                        ceshiVal =ceshiVal + valArr[i].id + ",";
                    }
                    $("input[name='successDataId']").val(ceshiVal);
                }else{
                    $("input[name='successDataId']").val("");
                }
            }else{
                if(obj.checked){
                    var ceshiVal = $("input[name='successDataId']").val();
                    $("input[name='successDataId']").val(ceshiVal + obj.data.id + ",");
                }else{
                    var ceshiVal = $("input[name='successDataId']").val();
                    var newVal = "";
                    var valArr = ceshiVal.split(obj.data.id+",");
                    for(var i=0;i<valArr.length;i++){
                        newVal += valArr[i];
                    }
                    $("input[name='successDataId']").val(newVal);
                }
            }
        });

    });
</script>
<!--</body>-->
<!--</html>-->